package leetCode.fourthWeek;

public class Code_75 {
  public void sortColors(int[] nums) {
    int[] sum = new int[3];
    int p = 0;
    for (int i = 0; i < nums.length; i++) {
      sum[nums[i]]++;
    }
    while (p < nums.length) {
      for (int i = 0; i < 3; i++) {
        if (sum[i] != 0) {
          nums[p] = i;
          sum[i]--;
          break;
        }
      }
      p++;
    }
  }
}
